<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class price extends CI_Controller { 
    public function index($idorder=FALSE){    
        $pricetotal = 0;
        if(!$idorder){
            return $pricetotal;
        }   
        else{
            $query = $this->db->query('SELECT * FROM DETILTRANSAKSI WHERE PB_IDDTLTRANSAKSI=?',array($idorder));
            if ($query->num_rows() == 1){
                $result = $query->row();
                
                //calculation here
                $jmlkertas = explode('-',$result->PB_HLMNCETAK);
                $intjmlkertas = $jmlkertas[1] - ($jmlkertas[0]-1);
                if($result->PB_WARNA=='WARNA'){
                    $pricetotal = $jmlkertas*1000;
                    return $pricetotal;
                }
                else{
                    $pricetotal = $jmlkertas*500;
                    return $pricetotal;                   
                }
            }
            else{
                return $pricetotal;
            }
        }
        
    } 
}
?>
